package com.project.personnel.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.project.personnel.dao.SalaryMapper;
import com.project.personnel.entity.Salary;
import com.project.personnel.service.SalaryService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author diaominyh
 * @since 2022-12-12
 */
@RestController
@RequestMapping("/salary")
public class SalaryController {
    @Resource
    private SalaryMapper salaryMapper;
    @Resource
    private SalaryService salaryService;
    @GetMapping("/salaryAll/{id}")
    //根据员工id查找salary表中的信息
    public Salary danAll(@PathVariable Integer id){
        QueryWrapper<Salary> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("id",id);
        Salary salary=salaryMapper.selectOne(queryWrapper);
        return salary;
    }
    @GetMapping("salaryName")
    public List<Salary> salaryName(){
        QueryWrapper<Salary> queryWrapper=new QueryWrapper<>();
        queryWrapper.select("name");
        List<Salary> salaryList=salaryMapper.selectList(queryWrapper);
        return salaryList;
    }
    @PutMapping("/salaryUpd")
    //修改员工账套
    public boolean salaryUpd(@RequestBody Salary salary){
        return salaryService.updateById(salary);
    }
}

